package com.foosun.context;

import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import com.foosun.util.ImageUtils;


public class EopSetting {


	/*
	 * 图片服务器域名
	 */
	public static String IMG_SERVER_DOMAIN = "static.foosungreenwild.com";

	public static String FILE_STORE_PREFIX = "fs:"; // 本地文件存储前缀

	public static String DEFAULT_IMG_URL = IMG_SERVER_DOMAIN + "/images/no_picture.jpg";

	public static String INFOR_DOMAIN = "http://42.96.176.134";
	
	public static final Map<String, String> CORP_SECRETS = new HashMap<String, String>();
	
	/*
	 * 从配置文件中读取相关配置<br/> 如果没有相关配置则使用默认
	 */
	static {
		try {
			InputStream in = null;
			ClassLoader classLoader = Thread.currentThread()
					.getContextClassLoader();
			if (classLoader != null) {
				in = classLoader.getResourceAsStream("server.properties");

			}
			Properties props = new Properties();
			props.load(in);
			init(props);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void init(Properties props) {
		
		String domain = props.getProperty("domain.imageserver");
		IMG_SERVER_DOMAIN = ImageUtils.isEmpty(domain) ? IMG_SERVER_DOMAIN : domain;
		IMG_SERVER_DOMAIN = IMG_SERVER_DOMAIN.startsWith("http://") ? IMG_SERVER_DOMAIN : "http://" + IMG_SERVER_DOMAIN;
		DEFAULT_IMG_URL = IMG_SERVER_DOMAIN + "/images/no_picture.jpg";

		String idomain = props.getProperty("domain.infordomain");
		INFOR_DOMAIN = ImageUtils.isEmpty(idomain) ? INFOR_DOMAIN : idomain;
		//initSafeUrl();
	}

	static {
		CORP_SECRETS.put("wx9aa55a020a3241a5", "vKmpPcxUQzIftjENOIv7HMEPHPBJwZRkFLrnSzrJ6H4w_3fXodQr4O8NOBsyCdD1");
	}

}